'use strict'

const { Service } = require('egg')
const svgCaptcha = require('svg-captcha')

class CaptchaService extends Service {
	async captcha() {
		const captcha = svgCaptcha.create({
			size: 4,
			fontSize: 50,
			ignoreChars: 'Ooli',
			width: 100,
			height: 40,
			noise: 3,
			color: true,
			background: '#FFFFFF',
		})
		this.ctx.session.code = captcha.text
		return captcha
	}
}

module.exports = CaptchaService
